
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>什么是策略模式 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../Java8系列.html" />
    
    
    <link rel="prev" href="proxy.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../开源组件实现.html">
            
                <a href="../开源组件实现.html">
            
                    
                    开源组件实现
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../mvc/MVC框架实现篇.html">
            
                <a href="../mvc/MVC框架实现篇.html">
            
                    
                    MVC框架实现篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1.1" data-path="../mvc/">
            
                <a href="../mvc/">
            
                    
                    MVC框架实现篇
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.2" data-path="../mvc/1.plan.html">
            
                <a href="../mvc/1.plan.html">
            
                    
                    项目规划
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.3" data-path="../mvc/2.route.html">
            
                <a href="../mvc/2.route.html">
            
                    
                    路由设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.4" data-path="../mvc/3.controller.html">
            
                <a href="../mvc/3.controller.html">
            
                    
                    控制器设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.5" data-path="../mvc/4.config.html">
            
                <a href="../mvc/4.config.html">
            
                    
                    配置设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.6" data-path="../mvc/5.view.html">
            
                <a href="../mvc/5.view.html">
            
                    
                    视图设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.7" data-path="../mvc/6.dbutil.html">
            
                <a href="../mvc/6.dbutil.html">
            
                    
                    数据库操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.8" data-path="../mvc/7.crud.html">
            
                <a href="../mvc/7.crud.html">
            
                    
                    增删改查
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../ioc/IOC容器实现篇.html">
            
                <a href="../ioc/IOC容器实现篇.html">
            
                    
                    IOC容器实现篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../ioc/1.concept.html">
            
                <a href="../ioc/1.concept.html">
            
                    
                    IOC的概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.2" data-path="../ioc/2.spring.html">
            
                <a href="../ioc/2.spring.html">
            
                    
                    Spring中怎么用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.3" data-path="../ioc/3.myioc.html">
            
                <a href="../ioc/3.myioc.html">
            
                    
                    设计一个IOC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.4" data-path="../ioc/4.principle.html">
            
                <a href="../ioc/4.principle.html">
            
                    
                    原理分析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../设计模式系列.html">
            
                <a href="../设计模式系列.html">
            
                    
                    设计模式系列
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="singleton.html">
            
                <a href="singleton.html">
            
                    
                    如何正确地写出单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="proxy.html">
            
                <a href="proxy.html">
            
                    
                    代理模式剖析
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.3" data-path="strategy.html">
            
                <a href="strategy.html">
            
                    
                    什么是策略模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Java8系列.html">
            
                <a href="../Java8系列.html">
            
                    
                    Java8系列
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../java8/java8-guide.html">
            
                <a href="../java8/java8-guide.html">
            
                    
                    Java8简明教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../java8/foreach.html">
            
                <a href="../java8/foreach.html">
            
                    
                    Java8 Foreach
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Hexo搭建博客.html">
            
                <a href="../Hexo搭建博客.html">
            
                    
                    Hexo搭建博客
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../hexo/hello.html">
            
                <a href="../hexo/hello.html">
            
                    
                    分分钟部署一个Hexo环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../hexo/config.html">
            
                <a href="../hexo/config.html">
            
                    
                    各种配置详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../hexo/writing.html">
            
                <a href="../hexo/writing.html">
            
                    
                    开始写作吧
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../开发者指南.html">
            
                <a href="../开发者指南.html">
            
                    
                    开发者指南
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../git/guide.html">
            
                <a href="../git/guide.html">
            
                    
                    git - 简明指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" >
            
                <a target="_blank" href="https://waylau.gitbooks.io/jersey-2-user-guide/content/index.html">
            
                    
                    Jersey-2.x用户指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" >
            
                <a target="_blank" href="https://waylau.gitbooks.io/rest-in-action/content/">
            
                    
                    REST 实战
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" >
            
                <a target="_blank" href="https://github.com/waylau/servlet-3.1-specification">
            
                    
                    Java Servlet 3.1 规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" >
            
                <a target="_blank" href="http://mybatis.github.io/mybatis-3/zh/index.html">
            
                    
                    MyBatis中文指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" >
            
                <a target="_blank" href="https://github.com/waylau/apache-shiro-1.2.x-reference">
            
                    
                    Apache Shiro 用户指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" >
            
                <a target="_blank" href="https://github.com/qibaoguang/Spring-Boot-Reference-Guide/blob/master/SUMMARY.md">
            
                    
                    Spring Boot参考指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" >
            
                <a target="_blank" href="https://github.com/waylau/netty-4-user-guide/blob/master/SUMMARY.md">
            
                    
                    Netty4 用户指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../user_guide/google-java8-guide.html">
            
                <a href="../user_guide/google-java8-guide.html">
            
                    
                    Google Java编程风格指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../运维相关.html">
            
                <a href="../运维相关.html">
            
                    
                    运维相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../web/test_tool.html">
            
                <a href="../web/test_tool.html">
            
                    
                    Web性能测试工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" >
            
                <a target="_blank" href="https://github.com/judasn/Linux-Tutorial">
            
                    
                    Java 程序员眼中的 Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../learn_server/">
            
                <a href="../learn_server/">
            
                    
                    写给java开发的运维笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../经典文章.html">
            
                <a href="../经典文章.html">
            
                    
                    经典文章
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../articles/request_message.html">
            
                <a href="../articles/request_message.html">
            
                    
                    HTTP请求报文解剖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../articles/software_architecture_patterns.html">
            
                <a href="../articles/software_architecture_patterns.html">
            
                    
                    软件架构模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../articles/electrical-business-architecture.html">
            
                <a href="../articles/electrical-business-architecture.html">
            
                    
                    电商网站架构案例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../服务器相关.html">
            
                <a href="../服务器相关.html">
            
                    
                    服务器/域名/SSL证书
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" >
            
                <a target="_blank" href="https://domainr.com">
            
                    
                    可用域名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" >
            
                <a target="_blank" href="http://hk.hostsir.com/Affiliates/i/d/976">
            
                    
                    优惠域名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" >
            
                <a target="_blank" href="http://www.vultr.com/?ref=6886447">
            
                    
                    vultr VPS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" >
            
                <a target="_blank" href="https://sshdropbear.net/">
            
                    
                    免费VPN/SSH服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" >
            
                <a target="_blank" href="http://get.ishadow.website/">
            
                    
                    免费SS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" >
            
                <span>
            
                    
                    1小时免费VPN
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.7" >
            
                <a target="_blank" href="https://saki.ssl.do/aff.php?aff=11">
            
                    
                    SSL.DO
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.8" >
            
                <a target="_blank" href="http://api.hostinger.com.hk/redir/22018310">
            
                    
                    免费虚拟主机
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../实用工具.html">
            
                <a href="../实用工具.html">
            
                    
                    实用工具/API
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" >
            
                <a target="_blank" href="https://tinypng.com/">
            
                    
                    PNG图片无损压缩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" >
            
                <a target="_blank" href="http://tool.c7sky.com/image-watermark/">
            
                    
                    在线给图片加水印
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" >
            
                <a target="_blank" href="http://tool.c7sky.com/password/">
            
                    
                    随机密码生成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" >
            
                <a target="_blank" href="https://randomuser.me/">
            
                    
                    随机头像生成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" >
            
                <a target="_blank" href="http://tool.c7sky.com/tcleaner/">
            
                    
                    微博一键清理工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" >
            
                <a target="_blank" href="http://csscompressor.com/">
            
                    
                    CSS压缩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" >
            
                <a target="_blank" href="http://www.atool.org/">
            
                    
                    在线工具
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >什么是策略模式</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4EC0;&#x4E48;&#x662F;&#x7B56;&#x7565;&#x6A21;&#x5F0F;">&#x4EC0;&#x4E48;&#x662F;&#x7B56;&#x7565;&#x6A21;&#x5F0F;</h1>
<ul>
<li><a href="#&#x7B56;&#x7565;&#x6A21;&#x5F0F;">&#x7B56;&#x7565;&#x6A21;&#x5F0F;</a><ul>
<li><a href="#&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5B9A;&#x4E49;">&#x4E00;&#x3001;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5B9A;&#x4E49;</a></li>
<li><a href="#&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5B9E;&#x9645;&#x5E94;&#x7528;">&#x4E8C;&#x3001;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5B9E;&#x9645;&#x5E94;&#x7528;</a></li>
<li><a href="#&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8BBE;&#x8BA1;&#x539F;&#x5219;">&#x4E09;&#x3001;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8BBE;&#x8BA1;&#x539F;&#x5219;</a></li>
</ul>
</li>
</ul>
<h2 id="&#x7B56;&#x7565;&#x6A21;&#x5F0F;">&#x7B56;&#x7565;&#x6A21;&#x5F0F;</h2>
<h3 id="&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5B9A;&#x4E49;">&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5B9A;&#x4E49;</h3>
<p><strong>&#x7B56;&#x7565;&#x6A21;&#x5F0F;</strong>&#xFF0C;&#x987E;&#x540D;&#x601D;&#x4E49;&#x5C31;&#x662F;&#x6307;&#x5BF9;&#x8C61;&#x5177;&#x6709;&#x67D0;&#x4E2A;&#x884C;&#x4E3A;&#xFF0C;&#x4F46;&#x662F;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x4E1A;&#x52A1;&#x573A;&#x666F;&#x4E0B;&#xFF0C;&#x8FD9;&#x4E2A;&#x884C;&#x4E3A;&#x5E94;&#x8BE5;&#x6709;&#x4E0D;&#x540C;&#x7684;&#x8868;&#x73B0;&#x5F62;&#x5F0F;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x6709;&#x4E86;&#x4E0D;&#x540C;&#x7684;&#x7B56;&#x7565;&#x3002;&#x8BA9;&#x5BF9;&#x8C61;&#x80FD;&#x518D;&#x4E0D;&#x540C;&#x7684;&#x573A;&#x666F;&#x4E0B;&#x5BF9;&#x540C;&#x4E00;&#x884C;&#x4E3A;&#x6709;&#x4E0D;&#x540C;&#x7684;&#x5B9E;&#x73B0;&#xFF0C;&#x8FD9;&#x5C31;&#x662F;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x662F;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x7C7B;&#x56FE;&#xFF1A; </p>
<p><img src="http://i.imgur.com/PE99rte.jpg" alt=""></p>
<ol>
<li>&#x9996;&#x5148;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7B56;&#x7565;&#x63A5;&#x53E3;&#xFF1A;<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Strategy</span> </span>{
 <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">algorithmStartegy</span><span class="hljs-params">()</span> </span>;
}
</code></pre>
</li>
<li>&#x5B9A;&#x4E49;&#x4E24;&#x4E2A;&#x5177;&#x4F53;&#x7684;&#x7B56;&#x7565;&#x7C7B;&#xFF1A;<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ConcentrateStrategy_1</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Strategy</span></span>{
 <span class="hljs-meta">@Override</span>
 <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">algorithmStartegy</span><span class="hljs-params">()</span> </span>{
     System.out.println(<span class="hljs-string">&quot;I am algorithm strategy 1&quot;</span>);
 }
}
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ConcentrateStrategy_2</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Strategy</span></span>{
 <span class="hljs-meta">@Override</span>
 <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">algorithmStartegy</span><span class="hljs-params">()</span> </span>{
     System.out.println(<span class="hljs-string">&quot;I am algorithm strategy 2&quot;</span>);
 }
}
</code></pre>
</li>
<li>&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7B97;&#x6CD5;&#x4F7F;&#x7528;&#x573A;&#x666F;<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Situation</span> </span>{
 Strategy strategy;
 <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Situation</span><span class="hljs-params">(Strategy strategy)</span> </span>{
     <span class="hljs-keyword">this</span>.strategy = strategy;
 }
 <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handleAlgorithm</span><span class="hljs-params">()</span> </span>{
     strategy.algorithmStartegy();
 }
}
</code></pre>
</li>
<li>&#x5BA2;&#x6237;&#x7AEF;&#x8C03;&#x7528;<pre><code class="lang-java">Situation situation = <span class="hljs-keyword">new</span> Situation(<span class="hljs-keyword">new</span> ConcentrateStrategy_1());
situation.handleAlgorithm();
 ...
</code></pre>
</li>
</ol>
<p>&#x4ECE;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x63CF;&#x8FF0;&#x4EE5;&#x53CA;&#x7C7B;&#x56FE;&#x6765;&#x770B;&#x771F;&#x7684;&#x662F;&#x975E;&#x5E38;&#x7B80;&#x5355;&#xFF0C;&#x603B;&#x7ED3;&#x8D77;&#x6765;&#x5C31;&#x662F;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x7EC4;&#x7B97;&#x6CD5;&#xFF0C;&#x5B83;&#x4EEC;&#x6709;&#x4E00;&#x4E2A;&#x5171;&#x540C;&#x7684;<strong>&#x7B56;&#x7565;&#x884C;&#x4E3A;&#x63A5;&#x53E3;</strong>&#xFF0C;&#x5E76;&#x4E14;&#x8FD9;&#x4E9B;&#x7B97;&#x6CD5;&#x4E4B;&#x95F4;&#x53EF;&#x4EE5;<strong>&#x4E92;&#x76F8;&#x66FF;&#x6362;</strong>&#xFF0C;&#x4F7F;&#x7B97;&#x6CD5;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x573A;&#x666F;&#x7684;&#x4E0D;&#x540C;&#x800C;&#x6539;&#x53D8;&#x3002;</p>
<h3 id="&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5B9E;&#x9645;&#x5E94;&#x7528;">&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5B9E;&#x9645;&#x5E94;&#x7528;</h3>
<p>&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x5E94;&#x7528;&#x6709;&#x5F88;&#x591A;&#xFF0C; &#x6BD4;&#x5982;&#x8BF4;JDK&#x4E2D;<code>FilenameFilter</code>&#x7684;&#x4F7F;&#x7528;&#x8FC7;&#x7A0B;&#xFF0C; &#x6BD4;&#x5982;&#x573A;&#x666F;<code>java.util.Collections.sort(List&lt;T&gt;list, Comparator&lt;? super T&gt;c)</code>&#x4E0E;&#x7B56;&#x7565;<code>java.util.Comparator</code>&#x7684;&#x4F7F;&#x7528;&#x7B49;&#x7B49;&#x3002;
&#x4E0B;&#x9762;&#x6211;&#x4EE5;&#x4E00;&#x4E2A;&#x5B9E;&#x9645;&#x7684;&#x4E1A;&#x52A1;&#x573A;&#x666F;&#x6765;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x4EE5;&#x4E0B;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#xFF1A;</p>
<ol>
<li>&#x80CC;&#x666F;&#xFF1A; &#x4E2D;&#x56FD;&#x94F6;&#x884C;&#x7684;&#x4FBF;&#x6C11;&#x670D;&#x52A1;&#x5305;&#x62EC;&#x4E2D;&#x56FD;&#x79FB;&#x52A8;&#x624B;&#x673A;&#x5145;&#x503C;&#xFF0C; &#x4E2D;&#x56FD;&#x8054;&#x901A;&#xFF0C;&#x4E2D;&#x56FD;&#x7535;&#x4FE1;&#x3002;&#x7528;&#x6237;&#x9009;&#x62E9;&#x67D0;&#x4E2A;&#x4FBF;&#x6C11;&#x670D;&#x52A1;&#x65F6;&#xFF0C; &#x670D;&#x52A1;&#x5668;&#x540E;&#x53F0;&#x4F1A;&#x5411;&#x94F6;&#x884C;&#x53D1;&#x9001;&#x4E0D;&#x540C;&#x7684;&#x4E1A;&#x52A1;XML&#x62A5;&#x6587;&#xFF0C; &#x5DF2;&#x8FBE;&#x5230;&#x901A;&#x4FE1;&#x76EE;&#x7684;&#x3002;</li>
<li><p>&#x5B9E;&#x73B0;</p>
<ol>
<li>&#x5B9A;&#x4E49;&#x7B56;&#x7565;&#x63A5;&#x53E3; : &#x5305;&#x542B;&#x4E00;&#x4E2A;&#x751F;&#x6210;&#x62A5;&#x6587;&#x7684;&#x65B9;&#x6CD5;<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">IProduct</span> </span>{
<span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">generateXML</span><span class="hljs-params">()</span> </span>;
}
</code></pre>
</li>
<li>&#x5B9A;&#x4E49;&#x4E00;&#x7EC4;&#x5177;&#x4F53;&#x7B56;&#x7565;&#x7C7B;&#xFF1A;<pre><code class="lang-java"><span class="hljs-meta">@XMLType</span>(<span class="hljs-string">&quot;Default&quot;</span>)
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DefaultHead</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">IProduct</span> </span>{
<span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">generateXML</span><span class="hljs-params">()</span> </span>{
 <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Defalut XML&quot;</span>;
}
}
<span class="hljs-meta">@XMLType</span>(<span class="hljs-string">&quot;ChinaMobile&quot;</span>)
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ChinaMobile</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">IProduct</span></span>{
<span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">generateXML</span><span class="hljs-params">()</span> </span>{
 <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;China Mobile XML&quot;</span>;
}
}
<span class="hljs-meta">@XMLType</span>(<span class="hljs-string">&quot;ChinaUnicom&quot;</span>)
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ChinaUnicom</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">IProduct</span> </span>{
<span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">generateXML</span><span class="hljs-params">()</span> </span>{
 <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Chinal Unicom XML&quot;</span>;
}
}
</code></pre>
</li>
<li>&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x573A;&#x666F;&#x7C7B;&#x7528;&#x4E8E;&#x751F;&#x6210;XML&#x62A5;&#x6587;<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">XMLGenerator</span> </span>{
<span class="hljs-keyword">private</span> IProduct product = <span class="hljs-keyword">new</span> DefaultHead();
<span class="hljs-comment">//&#x6839;&#x636E;&#x7528;&#x6237;&#x7F34;&#x8D39;&#x7C7B;&#x578B;&#xFF0C;&#x751F;&#x6210;&#x4E0D;&#x540C;&#x7684;&#x901A;&#x4FE1;&#x62A5;&#x6587;</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">generate</span><span class="hljs-params">(String type)</span> </span>{
 <span class="hljs-comment">//&#x6CE8;&#x610F;&#x6B64;&#x5904;</span>
 product = ProductFactory.getInstance().createProduct(type);
<span class="hljs-keyword">return</span> product.generateXML();
}
}
</code></pre>
</li>
<li><p>&#x521B;&#x5EFA;&#x5177;&#x4F53;&#x7684;&#x7B56;&#x7565;&#x7C7B;&#xFF0C; &#x672C;&#x6765;&#x662F;&#x53EF;&#x4EE5;&#x7528;&#x4E00;&#x7CFB;&#x5217;&#x7684;<code>if else</code>&#x5224;&#x65AD;&#xFF0C; &#x7136;&#x540E;new&#x76F8;&#x5E94;&#x7684;&#x7B56;&#x7565;&#x7C7B;&#x3002;&#x8FD9;&#x91CC;&#x4E3A;&#x4E86;&#x907F;&#x514D;<code>if else</code>&#x6211;&#x4EEC;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7B56;&#x7565;&#x5DE5;&#x5382;&#xFF0C;&#x6765;&#x751F;&#x4EA7;&#x5177;&#x4F53;&#x7684;&#x7B56;&#x7565;&#x7C7B;&#x3002;
<strong>&#x7B56;&#x7565;&#x7C7B;&#x5DE5;&#x5382;</strong>&#xFF1A;&#x8FD9;&#x4E2A;&#x5DE5;&#x5382;&#x521B;&#x5EFA;&#x7B56;&#x7565;&#x7C7B;&#x7684;&#x601D;&#x8DEF;&#x5C31;&#x662F;&#xFF0C;&#x8F7D;&#x5165;&#x4E00;&#x4E9B;&#x5217;&#x7B56;&#x7565;&#x7C7B;&#xFF0C;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x7B56;&#x7565;&#x7C7B;&#x7684;<strong>&#x81EA;&#x5B9A;&#x4E49;&#x6CE8;&#x89E3;</strong>&#x548C;&#x7528;&#x6237;&#x7684;&#x4F20;&#x5165;&#x53C2;&#x6570;&#x6765;&#x751F;&#x6210;&#x5177;&#x4F53;&#x7684;&#x7B56;&#x7565;&#x7C7B;&#x3002; 
```java
public class ProductFactory {
// singleton
private ProductFactory() {}</p>
<p>public static ProductFactory getInstance() {
 return ProductFactoryInstance.instance;
}</p>
<p>private static class ProductFactoryInstance {
 static final ProductFactory instance = new ProductFactory();
}</p>
<p>//&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7684;&#x7B56;&#x7565;&#x7C7B;
public IProduct createProduct(String productType) throws URISyntaxException {
 // load all startegys
 List<class<? extends="" iproduct="">&gt; startegyList = loadAllStrategy(&quot;com.su.startegy&quot;);
 //&#x904D;&#x5386;&#x6240;&#x6709;&#x7B56;&#x7565;&#x7C7B;&#xFF0C; &#x6839;&#x636E;&#x6761;&#x4EF6;&#x627E;&#x51FA;&#x9700;&#x8981;&#x7528;&#x5230;&#x7684;
 for(Class&lt;? extends IProduct&gt; clazz : startegyList) {</class<?></p>
<pre><code> //&#x89E3;&#x6790;&#x7B56;&#x7565;&#x7C7B;&#x7684;&#x6CE8;&#x89E3;
 XMLType xmlType = praseAnnotation(clazz);
 if(xmlType.value().equals(productType))
     try {
         return clazz.newInstance();
     } catch (InstantiationException | IllegalAccessException e)  {
         e.printStackTrace();
     }
 }
</code></pre><p> }
 //create IProduct Object failed
 return null;
}</p>
<p>//&#x8F7D;&#x5165;&#x7B56;&#x7565;&#x7C7B;&#x65B9;&#x6CD5;
private List<class<? extends="" iproduct="">&gt; loadAllStrategy(String packageName) throws URISyntaxException {
 //&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7B56;&#x7565;&#x7C7B;&#x7684;&#x5217;&#x8868;
 List<class<? extends="" iproduct="">&gt; strategyList = new ArrayList<class<? extends="" iproduct="">&gt;();
 URI filePath = getClass().getClassLoader().getResource(packageName.replace(&quot;.&quot;, &quot;/&quot;)).toURI();
 //&#x83B7;&#x53D6;filepath
 File[] files = new File(filePath).listFiles(new FilenameFilter() {</class<?></class<?></class<?></p>
<pre><code> @Override
 public boolean accept(File dir, String name) {
     if (name.endsWith(&quot;.class&quot;))
         return true;
     return false;
 }
</code></pre><p> });
 // load class
 for (File file : files) {</p>
<pre><code> try {
     Class clazz = getClass().getClassLoader().loadClass(packageName + &quot;.&quot; + file.getName().replace(&quot;.class&quot;, &quot;&quot;));
     if (clazz != IProduct.class &amp;&amp; IProduct.class.isAssignableFrom(clazz)) {
         strategyList.add(clazz);
     }
 } catch (ClassNotFoundException e) {
     e.printStackTrace();
 }
</code></pre><p> }
 return strategyList;
}</p>
<p>//&#x89E3;&#x6790;&#x6CE8;&#x89E3;&#x65B9;&#x6CD5;
private XMLType praseAnnotation(Class&lt;? extends IProduct&gt; clazz) {
 XMLType xmlType = clazz.getAnnotation(XMLType.class);
 if (xmlType == null) {</p>
<pre><code> return null;
</code></pre><p> }
 return xmlType;
}</p>
</li>
</ol>
</li>
</ol>
<p>}</p>
<pre><code>
&#x6B64;&#x5904;&#x6211;&#x4F7F;&#x7528;**&#x6CE8;&#x89E3;**&#x7684;&#x539F;&#x56E0;&#x662F;&#x4E3A;&#x4E86;&#x7B80;&#x5355;&#xFF0C; &#x8DDF;&#x4EE3;&#x7801;&#x7684;&#x8026;&#x5408;&#x7D27;&#x4E00;&#x70B9;&#x3002;

**&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x6CE8;&#x89E3;&#x7C7B;&#xFF1A; **

```java
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface XMLType {
    public String value() default &quot;defalut&quot;;
}
</code></pre><p>&#x4EE5;&#x4E0A;&#x5C31;&#x662F;&#x6B64;&#x5904;&#x7684;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x7684;&#x8BBE;&#x8BA1;&#x8FC7;&#x7A0B;&#xFF0C;&#x5982;&#x679C;&#x9700;&#x8981;&#x591A;&#x79CD;&#x7B56;&#x7565;&#x7684;&#x53E0;&#x52A0;&#xFF0C; &#x4E5F;&#x5C31;&#x8981;&#x76F8;&#x5E94;&#x7684;&#x4F7F;&#x7528;&#x6CE8;&#x89E3;&#x7684;&#x5D4C;&#x5957;&#x4E86;&#xFF0C; &#x8FD9;&#x91CC;&#x5C31;&#x4E0D;&#x5728;&#x53D1;&#x6325;&#x4E86;&#x3002;</p>
<h3 id="&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8BBE;&#x8BA1;&#x539F;&#x5219;">&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x4E2D;&#x7684;&#x8BBE;&#x8BA1;&#x539F;&#x5219;</h3>
<p>&#x5B66;&#x4E60;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#xFF0C; &#x4E0D;&#x8981;&#x8BB0;&#x4F4F;&#x4EE3;&#x7801;&#x662F;&#x600E;&#x4E48;&#x5B9E;&#x73B0;&#x7684;&#xFF0C;&#x66F4;&#x91CD;&#x8981;&#x7684;&#x662F;&#x8BB0;&#x4F4F;&#x5176;&#x8BBE;&#x8BA1;&#x539F;&#x5219;&#x3002;&#x6839;&#x636E;&#x539F;&#x5219;&#x5199;&#x4EE3;&#x7801;&#xFF0C; &#x800C;&#x4E0D;&#x662F;&#x751F;&#x642C;&#x786C;&#x5957;&#x3002;&#x5176;&#x5B9E;&#x8BBE;&#x8BA1;&#x6A21;&#x5F0F;&#x90FD;&#x662F;&#x8BBE;&#x8BA1;&#x539F;&#x5219;&#x7684;&#x4F53;&#x73B0;&#xFF0C; &#x5982;&#x679C;&#x7406;&#x89E3;&#x4E86;&#x8BBE;&#x8BA1;&#x539F;&#x5219;&#xFF0C; &#x90A3;&#x4E48;&#x4F60;&#x5199;&#x7684;&#x4EE3;&#x7801;&#x4E5F;&#x53EF;&#x4EE5;&#x53D8;&#x6210;&#x4E00;&#x79CD;&#x6A21;&#x5F0F;&#x3002;</p>
<ol>
<li><p><strong>&#x5F00;&#x95ED;&#x539F;&#x5219;&#xFF08;Open-Closed Principle&#xFF0C;&#x7F29;&#x5199;&#x4E3A;OCP&#xFF09;</strong>
&#x4E00;&#x4E2A;&#x8F6F;&#x4EF6;&#x5B9E;&#x4F53;&#x5E94;&#x5F53;&#x5BF9;&#x6269;&#x5C55;(&#x4F8B;&#x5982;&#x5BF9;&#x62BD;&#x8C61;&#x5C42;&#x7684;&#x6269;&#x5C55;)&#x5F00;&#x653E;&#xFF0C;&#x5BF9;&#x4FEE;&#x6539;(&#x4F8B;&#x5982;&#x5BF9;&#x62BD;&#x8C61;&#x5C42;&#x7684;&#x4FEE;&#x6539;)&#x5173;&#x95ED;&#x3002;&#x5373;&#x5728;&#x8BBE;&#x8BA1;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5E94;&#x5F53;&#x4F7F;&#x8FD9;&#x4E2A;&#x6A21;&#x5757;&#x53EF;&#x4EE5;&#x5728;&#x4E0D;&#x88AB;&#x4FEE;&#x6539;&#x7684;&#x524D;&#x63D0;&#x4E0B;&#x88AB;&#x6269;&#x5C55;&#x3002;
&#x5F00;&#x95ED;&#x539F;&#x5219;&#x7684;&#x5173;&#x952E;&#xFF0C;&#x5728;&#x4E8E;&#x62BD;&#x8C61;&#x3002;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#xFF0C;&#x662F;&#x5F00;&#x95ED;&#x539F;&#x5219;&#x7684;&#x4E00;&#x4E2A;&#x6781;&#x597D;&#x7684;&#x5E94;&#x7528;&#x8303;&#x4F8B;&#x3002;</p>
</li>
<li><p><strong>&#x91CC;&#x6C0F;&#x66FF;&#x6362;&#x539F;&#x5219;&#xFF08;Liskov Substitution Principle&#xFF0C;&#x7F29;&#x5199;&#x4E3A;LSP&#xFF09;</strong>
&#x4E00;&#x4E2A;&#x8F6F;&#x4EF6;&#x5B9E;&#x4F53;&#x5982;&#x679C;&#x4F7F;&#x7528;&#x7684;&#x662F;&#x4E00;&#x4E2A;&#x57FA;&#x7C7B;&#x7684;&#x8BDD;&#xFF0C;&#x90A3;&#x4E48;&#x4E00;&#x5B9A;&#x9002;&#x7528;&#x4E8E;&#x5176;&#x5B50;&#x7C7B;&#xFF0C;&#x800C;&#x4E14;&#x5B83;&#x6839;&#x672C;&#x4E0D;&#x80FD;&#x5BDF;&#x89C9;&#x5230;&#x57FA;&#x7C7B;&#x5BF9;&#x8C61;&#x548C;&#x5B50;&#x7C7B;&#x5BF9;&#x8C61;&#x7684;&#x533A;&#x522B;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x5047;&#x8BBE;&#x6709;&#x4E24;&#x4E2A;&#x7C7B;&#xFF0C;&#x4E00;&#x4E2A;&#x662F;Base&#x7C7B;&#xFF0C;&#x4E00;&#x4E2A;&#x662F;Derived&#x7C7B;&#xFF0C;&#x5E76;&#x4E14;Derived&#x7C7B;&#x662F;Base&#x7C7B;&#x7684;&#x5B50;&#x7C7B;&#x3002;&#x90A3;&#x4E48;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x5982;&#x679C;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x57FA;&#x7C7B;&#x5BF9;&#x8C61;b&#x7684;&#x8BDD;&#xFF1A;method1(Base b)&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x5FC5;&#x7136;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x5B50;&#x7C7B;&#x5BF9;&#x8C61;d&#xFF0C;&#x4E5F;&#x5373;&#x53EF;&#x4EE5;&#x6709;method1(d)&#x3002;&#x53CD;&#x4E4B;&#xFF0C;&#x5219;&#x4E0D;&#x4E00;&#x5B9A;&#x6210;&#x7ACB;
&#x91CC;&#x6C0F;&#x66FF;&#x6362;&#x539F;&#x5219;&#x8BB2;&#x7684;&#x662F;&#x57FA;&#x7C7B;&#x4E0E;&#x5B50;&#x7C7B;&#x7684;&#x5173;&#x7CFB;&#x3002;&#x53EA;&#x6709;&#x5F53;&#x8FD9;&#x79CD;&#x5173;&#x7CFB;&#x5B58;&#x5728;&#x65F6;&#xFF0C;&#x91CC;&#x6C0F;&#x66FF;&#x6362;&#x5173;&#x7CFB;&#x624D;&#x5B58;&#x5728;&#xFF0C;&#x53CD;&#x4E4B;&#x5219;&#x4E0D;&#x5B58;&#x5728;&#x3002;</p>
</li>
</ol>
<p>&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x4E4B;&#x6240;&#x4EE5;&#x53EF;&#x884C;&#x7684;&#x57FA;&#x7840;&#x4FBF;&#x662F;&#x91CC;&#x6C0F;&#x66FF;&#x6362;&#x539F;&#x5219;&#xFF1A;&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x8981;&#x6C42;&#x6240;&#x6709;&#x7684;&#x7B56;&#x7565;&#x5BF9;&#x8C61;&#x90FD;&#x662F;&#x53EF;&#x4EE5;&#x4E92;&#x6362;&#x7684;&#xFF0C;&#x56E0;&#x6B64;&#x5B83;&#x4EEC;&#x90FD;&#x5FC5;&#x987B;&#x662F;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x7B56;&#x7565;&#x89D2;&#x8272;&#x7684;&#x5B50;&#x7C7B;&#x3002;&#x5728;&#x5BA2;&#x6237;&#x7AEF;&#x5219;&#x4EC5;&#x77E5;&#x9053;&#x62BD;&#x8C61;&#x7B56;&#x7565;&#x89D2;&#x8272;&#x7C7B;&#x578B;&#xFF0C;&#x867D;&#x7136;&#x53D8;&#x91CF;&#x7684;&#x771F;&#x5B9E;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7B56;&#x7565;&#x89D2;&#x8272;&#x7684;&#x5B9E;&#x4F8B;</p>
<h2 id="&#x53C2;&#x8003;&#x6587;&#x732E;">&#x53C2;&#x8003;&#x6587;&#x732E;</h2>
<p><a href="http://blog.csdn.net/caihaijiang/article/details/8764226" target="_blank">&#x7B56;&#x7565;&#x6A21;&#x5F0F;&#x8BBE;&#x8BA1;&#x539F;&#x5219;</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="proxy.html" class="navigation navigation-prev " aria-label="Previous page: 代理模式剖析">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../Java8系列.html" class="navigation navigation-next " aria-label="Next page: Java8系列">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"什么是策略模式","level":"1.3.3","depth":2,"next":{"title":"Java8系列","level":"1.4","depth":1,"path":"Java8系列.md","ref":"Java8系列.md","articles":[{"title":"Java8简明教程","level":"1.4.1","depth":2,"path":"java8/java8-guide.md","ref":"java8/java8-guide.md","articles":[]},{"title":"Java8 Foreach","level":"1.4.2","depth":2,"path":"java8/foreach.md","ref":"java8/foreach.md","articles":[]}]},"previous":{"title":"代理模式剖析","level":"1.3.2","depth":2,"path":"designpatterns/proxy.md","ref":"designpatterns/proxy.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"designpatterns/strategy.md","mtime":"2017-09-01T15:31:07.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2017-09-01T16:57:38.335Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

